import {reqCategoryList,reqBannerList} from '@/api'
//四大核心属性
//state :仓库的数据来源
const state = {
    categoryList:[],
    //轮播图的数据
    bannerList:[]
};
//mutation:唯一改变state数据的地方
const mutations = {
    GETCATEGORY(state,result){
        state.categoryList = result
    },
    GETBANNER(state,result){
        state.bannerList = result
    }
}
//actions:可以处理dispatch 派发 action 的地方，这里可以书写你的业务逻辑
//for if 异步语句等等
const actions ={
    async getCategory({commit}){
       let result = await reqCategoryList();
     if(result.code == 200){
        commit('GETCATEGORY', result.data)
     }// console.log(result.data)测试是否请求回来的数据
    },
    //获取banner首页轮播图的数据
   async  getBannerList({commit}){
      let result = await  reqBannerList();
    //   console.log(result)
    if(result.code == 200){
        commit('GETBANNER',result.data)
    }
  
    }
}
const getters = {

}

export default {
    state,
    mutations,
    actions,
    getters
}